package com.dxt.rabbitmq.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * fanout类型的交换机（广播）
 * 不需要指定routing_key
 */
@Component
public class FanoutModeConfig {
    public static final String QUEUE1 = "fanout_queue_one";
    public static final String QUEUE2 = "fanout_queue_two";
    public static final String EXCHANGE = "fanout_exchange";

    @Bean
    public Queue fanoutModeQueue1(){
        return new Queue(FanoutModeConfig.QUEUE1);
    }

    @Bean
    public Queue fanoutModeQueue2(){
        return new Queue(FanoutModeConfig.QUEUE2);
    }
    @Bean
    public FanoutExchange fanoutModeExchange(){
        return new FanoutExchange(FanoutModeConfig.EXCHANGE);
    }

    @Bean
    public Binding fanoutModeBinding1(){
        return BindingBuilder.bind(fanoutModeQueue1()).to(fanoutModeExchange());
    }

    @Bean
    public Binding fanoutModeBinding2(){
        return BindingBuilder.bind(fanoutModeQueue2()).to(fanoutModeExchange());
    }
}
